﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Diagnostics;
using System.Reflection;
using System.Collections; 
using System.Web.UI;
using LigerMVC.Common;

namespace LigerMVC.Common.Extensions
{
    /// <summary>
    /// 扩展方法
    /// </summary>
    public static class NumberExtension
    {  
        /// <summary>
        /// 转换为Double类型
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        public static double ToDouble(this decimal value)
        {
            return Convert.ToDouble(value);
        }

        /// <summary>
        /// 判断一个整数是否为有效的 Id，增强代码可读性
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        public static bool IsId(this int value)
        {
            return value > 0;
        }

        /// <summary>
        /// 判断数值是否在指定的范围内
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="t"></param>
        /// <param name="minT"></param>
        /// <param name="maxT"></param>
        /// <returns></returns>
        public static bool InRange<T>(this IComparable<T> t, T minT, T maxT)
        {
            return t.CompareTo(minT) >= 0 && t.CompareTo(maxT) <= 0;
        }
    }

            
}
